DEFINITION MODULE ApplMgr;

(*
AES Application Manager.

UK __DATE__ __TIME__
*)

(*DEF_SWITCHES*)

FROM PORTAB IMPORT ANYBYTE,ANYWORD,SIGNEDWORD,UNSIGNEDWORD,ANYTYPE,
                   ANYPOINTER,WORDSET,UNSIGNEDLONG;
FROM RcMgr  IMPORT GPnt;

IMPORT AES;

#if export
EXPORT QUALIFIED ApplInit,ScrMgr,ApplRead,ApplWrite,ApplFind,
                 ScanWord,Key,SpecialKey,RecordEvents,EventRecord,MaxEvent,
                 EventTape,TapePtr,ApplTPlay,ApplTRecord,
                 ApplBVSet,ApplYield,
                 ApSFirst,ApSNext,ApSShel,ApKSys,ApKApp,ApKAcc,ApplSearch,
                 ApplExit,applinit,applexit;
#endif

(* [Appl]ication Manager: [Init]ialize Application, AES(10) ****************)

VAR ApplInit: PROCEDURE(): SIGNEDWORD;

(* [Appl]ication Manager: [Read] From Application, AES(11) *****************)

CONST ScrMgr = 1; (* ID of the screen manager *)

PROCEDURE ApplRead(    Id     : SIGNEDWORD;
                       Length : UNSIGNEDWORD;
                   VAR PBuffer: ARRAY OF ANYTYPE): BOOLEAN;

(* [Appl]ication Manager: [Write] TO Application, AES(12) ******************)

PROCEDURE ApplWrite(    Id     : SIGNEDWORD;
                        Length : UNSIGNEDWORD;
                    VAR PBuffer: ARRAY OF ANYTYPE);

(* [Appl]ication Manager: [Find] Application, AES(13) **********************)

PROCEDURE ApplFind(PName: ANYPOINTER): SIGNEDWORD;

(* [Appl]ication Manager: [Play] Event [T]ape, AES(14) *********************)

TYPE ScanWord = AES.ScanWord;

     Key = AES.Key;

     SpecialKey = AES.SpecialKey;

     RecordEvents = (EvTimer,EvButton,EvMouse,EvKeybd);

     EventRecord = RECORD
#if ST
                     Resvd: ANYWORD;
#endif

#if linear
#if fill_byte
                     FillByte1: ANYBYTE;
#endif
#endif
                     Type : RecordEvents;
#if intel
#if fill_byte
                     FillByte1: ANYBYTE;
#endif
#endif
                     Info : RECORD
                              CASE: RecordEvents OF
                                EvTimer:
                                  Time: UNSIGNEDLONG;
                              | EvButton:
                                  Clicks: UNSIGNEDWORD;
#if linear
#if fill_byte
                                  FillByte2: ANYBYTE;
#endif
#endif
                                  State: BOOLEAN;
#if intel
#if fill_byte
                                  FillByte2: ANYBYTE;
#endif
#endif
                              | EvMouse:
                                  Position: GPnt;
                              | EvKeybd:
                                  Special: SpecialKey;
                                  Input  : Key;
                              END;
                            END;
                   END;

CONST MaxEvent = 4095;

TYPE EventTape = [0..(MaxEvent  - 1)];
     TapePtr = POINTER TO ARRAY EventTape OF EventRecord;

PROCEDURE ApplTPlay(PTape : TapePtr;
                    Length: EventTape;
                    Scale : UNSIGNEDWORD);

(* [Appl]ication Manager: [Record] Event [T]ape, AES(15) *******************)

PROCEDURE ApplTRecord(PTape : TapePtr;
                      Length: EventTape): EventTape;

(* [Appl]ication Manager: [Set] Drive [B]it [V]ectors, AES(16) *************)

PROCEDURE ApplBVSet(BVDisk: WORDSET;
                    BVHard: WORDSET);

(* [Appl]ication Manager: [Yield] Application, AES(17) *********************)

PROCEDURE ApplYield;

(* [Appl]ication Manager: [Search] Application, AES(18) ********************)

CONST ApSFirst = 0;
      ApSNext  = 1;
      ApSShel  = 2;

CONST ApKSys = 01H;
      ApKApp = 02H;
      ApKAcc = 04H;

PROCEDURE ApplSearch(    Mode: UNSIGNEDWORD;
                     VAR Name: ARRAY OF CHAR;
                     VAR Type: UNSIGNEDWORD;
                     VAR Id  : UNSIGNEDWORD): BOOLEAN;

(* [Appl]ication Manager: [Exit] Application, AES(19) **********************)

VAR ApplExit: PROCEDURE();

(***************************************************************************)

PROCEDURE applinit(): SIGNEDWORD;

PROCEDURE applexit;

END ApplMgr.
